package com.nwpusp.display.views.components;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;

import com.example.petssports.R;
import com.nwpusp.display.GlobalVar;

public class NameBar extends View{
	public Bitmap nameBitmap;
	public float x;
	public float y;
	public float scale;
	public float width;
	public float height;
	public String name;
	public int index;
	
	public NameBar(Context view,float scale){
		super(view);
		this.scale = scale;
		getBitmapSource();
		nameBitmap = GlobalVar.VerticalScale(nameBitmap,scale);
		width = nameBitmap.getWidth();
		height = nameBitmap.getHeight();
	}
	
	public void setLocation(float x ,float y){
		this.x = x;
		this.y = y;
	}
	
	public void setName(String str){
		this.name = str;
		nameBitmap = GlobalVar.DrawSubList(width,height,nameBitmap,name,24);
	}
	
	private void getBitmapSource(){
		nameBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.namebar);
	}
	
	public boolean isClick(float xl,float yl){
		if((xl>x) && (xl<x+width)&&(yl>y)&&(yl<y+height)){
			GlobalVar.whichServer = index;
			return true;
		}
		else
			return false;
	}
	
	public Bitmap draw(){
		return nameBitmap;
	}

}
